package cn.qf;

import java.util.Arrays;
import java.util.Date;

public class TextBook {

    // 属性
    String title; // 书名
    String[] author; // 作者
    String publisher; // 出版社
    String isbn; // 书号

    String subject; // 主题
    Date publishDate; // 出版日期

    // 初始化代码块
    {
        this.title = "";
        this.publishDate = new Date();
    }

    // 构造方法：用于初始化类的实例对象
    public TextBook() {}

    public TextBook(String bookTitle, String[] author, String subject) {
        // this.title = title;
        title = bookTitle;
        this.author = author;
        this.subject = subject;
    }

    public TextBook(String title, String[] author, String subject, String publisher, String isbn) {
        // 使用 this() 调用其它的构造方法
        this(title, author, subject);

        this.publisher = publisher;
        this.isbn = isbn;

        this.publishDate = new Date();
    }

    // 方法
    // public 作为访问控制修饰符，用于标识 publish() 方法允许在其他类中被调et
    public void publish(String publisher, String isbn){
        // this 关键字，它代表当前实例对象的引用
        this.publisher = publisher;
        this.isbn = isbn;

        this.publishDate = new Date();
    }

    public String toString() {
       return "书名：" + title + "\n"
               + "作者：" + Arrays.toString(author) + "\n"
               + "出版社：" + publisher + "\n"
               + "书号：" + isbn + "\n"
               + "主题：" + subject;
    }
}
